import Vue from 'vue'
import Router from 'vue-router'
import templateRouter from './templateRouter'
import customRouter from './customRouter'
import getDemoRouter from './getDemoRouter'
import enumRouter from "./enumRouter";

Vue.use(Router)

export const constantRouterMap = [
  {
    name: 'Login',
    path: '/login',
    component: () => import(`@/project/index/pages/login/index.vue`)
  },
  {
    name: 'Home',
    path: '/project',
    component: () => import(`@/project/index/pages/home/index.vue`),
    children: [
      {
        name: 'HomeWelcode',
        path: '/project',
        component: () => import(`@/project/index/pages/enumPage/welcome/index.vue`),
      },
      ...templateRouter,
      ...customRouter,
      ...getDemoRouter,
      ...enumRouter,
      // 如果找不到就显示404界面
      { path: '*', redirect: '/project' },
    ]
  },
  // 如果找不到就显示404界面
  { path: '*', redirect: '/project' },
]

const router = new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0, x: 0 }),
  routes: constantRouterMap,
})

router.beforeEach((to, from, next) => {
  next()
})

export default router
